{% extends "base.html" %}
  {% block content %}
    {% from "forms/macros.html" import render_field_busqueda %}
       <SCRIPT LANGUAGE="JavaScript">
	
		url_1 = "/atributo/modificar/ID/"
		url_2 = "/atributo/eliminar/ID/"
		url_3 = "/atributo/consultar/ID/"
		
		id_href_1 = 'modificar'
		id_href_2 = 'eliminar'
		id_href_3 = 'consultar'
 
		function obtener_id(id) {
        	link_1 = document.getElementById(id_href_1)
        	link_2 = document.getElementById(id_href_2)
        	link_3 = document.getElementById(id_href_3)
        	new_url_1 = url_1.replace('ID', id)
        	new_url_2 = url_2.replace('ID', id)
        	new_url_3 = url_3.replace('ID', id)
        	link_1.href = new_url_1
        	link_2.href = new_url_2
        	link_3.href = new_url_3
        
		}
		
		function pregunta(){
    		if(confirm('Esta seguro de que desea eliminar el atributo?')){
    			return true;
    		}else{
    			return false;
    		}
    	}
   
    
    </SCRIPT>
    <form method="POST" action={{ url_for('atributos.administracion_atributo') }} class="form">
   		{{ form.csrf_token }} 	
   	   	 <table> 
     	 		<tr >
     	 	 		<th></th>
  			 		<th>  <label>Filtro</label> </th>
     		 		<th>{{ render_field_busqueda(form.nombre, class="input text") }}</th>
     		  		<th>{{ render_field_busqueda(form.tipo, class="input text") }}</th>
     		  		<th>{{ render_field_busqueda(form.descripcion, class="input text") }}</th>     		  		
      			</tr >  			
  				<tr >
  			 		<th></th>
  			 		<th> <center>ID </center></th>
      		 		<th> <center> NOMBRE <c/enter></td>
      				 <th> <center> TIPO <c/enter></td>
      				 <th> <center> DESCRIPCION <c/enter></td>
      				       			</tr >  		
				{% for atributo in atributos %}			
   					<tr >
   				 		<th><input type = "radio" name = "seleccionado" id="select" onchange="obtener_id({{atributo.id}})"></th>
      			  		<td> <center>{{ atributo.id }} </center></td>
      			  		<td> <center>{{ atributo.nombre }} <center></td>
      			  		<td> <center>{{ atributo.tipo }} <center></td>
      			  		<td> <center>{{ atributo.descripcion }} <center></td>      			  		
      			  		
   					</tr>  		 	
				{% endfor %}				
		
		</table> 
	    	 
   		<button type="submit" class="button green">
                Buscar
   		</button>
   		<button type="submit" class="button green">
		                <a href="{{ url_for('atributos.crear_atributo') }}">Crear</a>
		</button>   
		 <button type="submit" class="button green">
               	<a href="" id="modificar">Modificar</a>
        </button>
        <button type="submit" class="button green">
                <a href="" id="consultar">Consultar</a>
        </button>
		<button type="submit"  onclick =  "return pregunta()">
        		<a href="" id="eliminar">Eliminar</a>
        </button> 
    
    </form>    
  {% endblock %}